package com.cms.pms;

import java.util.Map;

/**
 * PMS 组件上下文
 * @author zhoushuang
 *
 */
public class PMSContext {

	volatile private static Context context;
	
	private static Aggregator aggregator;
	
	private static Processor processor;
	
	private static Configuration configuration;
	
	private static Parser parser;
		
	public static Parser getParser() {
		return parser;
	}

	public static void setParser(Parser parser) {
		PMSContext.parser = parser;
	}

	public static Configuration getConfiguration() {
		return configuration;
	}

	public static void setConfiguration(Configuration configuration) {
		PMSContext.configuration = configuration;
	}

	public static Processor getProcessor() {
		return processor;
	}

	public static void setProcessor(Processor processor) {
		PMSContext.processor = processor;
	}

	public static Aggregator getAggregator() {
		return aggregator;
	}

	public static void setAggregator(Aggregator aggregator) {
		PMSContext.aggregator = aggregator;
	}
	

	static{
//		PMSContext.context = new DefaultContext();
//		PMSContext.aggregator = new SimpleAggregator();
//		PMSContext.processor = new ProcessorImpl();
//		PMSContext.processor.start();
	}

	public static void setContext(Context context) {
		PMSContext.context = context;
	}

	public static Context getContext() {
		return PMSContext.context;
	}

	public static Map<Thread, Store> getAllStore() {
		return PMSContext.context.getAllStore();
	}

	public static Store getStore() {
		return PMSContext.context.getStore();
	}
}
